<?php

/**
 * 无权限全局集成类
 * @author wyb
 */

namespace Seller\Controller;

use Think\Controller;

class CommController extends Controller {

    protected $__row = 12; //列表显示条数
    protected $__page = 0; //当前页数
    protected $__goods_stock_warning = 20; //商品库存预警
	protected $__goods_advent_warning = 5;
    protected $_soller_login_key = 'SOLLER_LOGIN_KEY_DATA'; //商家登录KEY
    protected $__post = array(); //post提交上来的数据
    protected $__get = array(); //get提交上来的数据

    protected function _initialize() {
        $this->__post = I('post.');
        $this->__get = I('get.');
        if (isset($this->__get['p'])) {
            $this->__page = $this->__get['p'];
        }
    }

    /**
     * 分页信息
     * @param int $total 数据总数
     */
    protected function __assignPage($total) {
        if ($total > $this->__row) {
            $page_gen = new \Think\Page($total, $this->__row);
            $this->assign('page', $page_gen->show());
        }
        $this->assign('count', $total);
        $this->assign('nowPage', ( $this->__page ? $this->__page : 1));
    }
    
    


    public function getCategory($pid,$str){
        
        $data = M('goods_type')->where(array('pid'=>$pid))->select();
       
        if($data){
            foreach ($data as $key =>$val){
                $str.=','.$val['id'];
                $str = $this->getCategory($val['id'],$str);
                
            }
        }
            return $str;
        
       
    }
    
    /**
     * 商家是否登录
     */
    protected function __checkedLogin() {
        if (isset($_SESSION[$this->_soller_login_key]) && $_SESSION[$this->_soller_login_key]) {
            $this->__seller_info = $_SESSION[$this->_soller_login_key];
            return true;
        }
        exit('<script> parent.window.location.href="' . U('Public/login') . '"; </script>');
    }

}
